home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / tptc17tc.zip / SMALLREC.PAS < prev    next >
Pascal/Delphi Source File  |  1988-03-25  |  868b  |  38 lines

  1.  
  2. (*
  3.  * Example of array subscripting
  4.  *)
  5.  
  6. program A_Small_Record;
  7.  
  8. type 
  9.      Description = record
  10.        Year    : integer;
  11.        Model   : string[20];
  12.        Engine  : string[8];
  13.      end;
  14.  
  15. var  
  16.      Cars  : array[1..10] of Description;
  17.      Index : integer;
  18.  
  19. begin  (* main program *)
  20.    for Index := 1 to 10 do begin
  21.       Cars[Index].Year := 1930 + Index;   {should be ...[index-1]}
  22.       Cars[Index].Model := 'Duesenburg';
  23.       Cars[Index].Engine := 'V8';
  24.    end;
  25.  
  26.    Cars[2].Model := 'Stanley Steamer';
  27.    Cars[2].Engine := 'Coal';
  28.    Cars[7].Engine := 'V12';
  29.    Cars[9].Model := 'Ford';
  30.    Cars[9].Engine := 'rusted';
  31.  
  32.    for Index := 1 to 10 do begin
  33.       Write('My ',Cars[Index].Year:4,' ');
  34.       Write(Cars[Index].Model,' has a ');
  35.       Writeln(Cars[Index].Engine,' engine.');
  36.    end;
  37. end.  (* of main program *)
  38.